package com.jzd1997.lesson20;

import org.junit.Test;

/**
 * @Author: jiangzd
 * @Date: 10:55 2019/7/26
 */
public class TestSingleton {
    @Test
    public void testHangryMode(){
        System.out.println("饿汉单例开始");
        for(int i=0;i<10;i++){
            new Thread(() -> LazySingleton.getInstance()).start();
        }
    }

    @Test
    public void testLaztSingleton(){
        System.out.println("懒汉单例开始");
        for(int i=0;i<10;i++){
            new Thread(() -> LazySingleton.getInstance()).start();
        }
    }

    @Test
    public void testLaztSingletonSync(){
        System.out.println("懒汉同步锁单例开始");
        for(int i=0;i<10;i++){
            new Thread(() -> LazySingletonSync.getInstance()).start();
        }
    }
}
